package io.itit.ecp.admin.server.service.impl;

import icu.mhb.mybatisplus.plugln.base.service.impl.JoinServiceImpl;
import io.itit.ecp.admin.server.entity.EnergyCategoryEntity;
import io.itit.ecp.admin.server.mapper.EnergyCategoryMapper;
import io.itit.ecp.admin.server.service.IEnergyCategoryService;
import io.itit.grass.common.exception.GrassException;
import org.springframework.stereotype.Service;


@Service
public class EnergyCategoryServiceImpl extends JoinServiceImpl<EnergyCategoryMapper, EnergyCategoryEntity>
        implements IEnergyCategoryService {

    @Override
    public EnergyCategoryEntity primaryEnergy() {
        return lambdaQuery().eq(EnergyCategoryEntity::getCategoryName, "一次能源").oneOpt().orElseThrow(() -> new GrassException("一次能源不存在"));
    }

    @Override
    public EnergyCategoryEntity othersEnergy() {
        return lambdaQuery().eq(EnergyCategoryEntity::getCategoryName, "其他").oneOpt().orElseThrow(() -> new GrassException("其他不存在"));
    }
}
